cmake_minimum_required(VERSION 3.0.0)
project(MyProject VERSION 0.1.0)

set(top ${CMAKE_CURRENT_SOURCE_DIR})



option(ON_WIN "Is this run on windows" OFF)


#set(CMAKE_SYSTEM Linux)
set(CMAKE_SYSTEM  Windows)

if (ON_WIN)
    option(SHARE_ENABLED "Build share lib" OFF)
    option(CROSS_ENABLED "Build on aarch64" OFF)
    add_subdirectory(windows)
    set(winlib win_dll)
else()
    option(SHARE_ENABLED "Build share lib" ON)
    option(CROSS_ENABLED "Build on aarch64" OFF)
    set(winlib "")
endif()

if (CROSS_ENABLED)
    #set(CMAKE_SYSROOT /Downloads/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/aarch64-linux-gnu/libc)
    set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
    set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
endif()

if (SHARE_ENABLED)
    set(share SHARED)
endif()

message(STATUS "top: ${top}")
message(STATUS "CROSS_ENABLED: ${CROSS_ENABLED}")
message(STATUS "SHARE_ENABLED: ${SHARE_ENABLED}")
message(STATUS "CMAKE_SYSROOT: ${CMAKE_SYSROOT}")
message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")



add_subdirectory(lib)

#define a macro MAIN in main.c
add_definitions(-DMAIN)

add_executable(app main.c)
target_include_directories(app PRIVATE .)
target_link_libraries(app PRIVATE ${winlib} hello_cpp)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})